package com.wedimob.slideshare.bo;

import com.google.gson.Gson;

public abstract class AbstractBO<T> {

    @SuppressWarnings("unchecked")
    public static <T> T fromString(String json) {
        try {
            Gson gson = new Gson();
            return (T) gson.fromJson(json, Class.forName(Thread.currentThread().getStackTrace()[2].getClassName()));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public String toString() {
        Gson gson = new Gson();
        return gson.toJson(this);
    }
}
